<%@page import="com.mixed.db.model.User"%>
<%@page import="org.apache.commons.dbutils.handlers.BeanListHandler"%>
<%@page import="com.mixed.db.dbutil.DbUtilHelper"%>
<%@page import="org.apache.commons.dbutils.QueryRunner"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'dbutil_test.jsp' starting page</title>
	<meta http-equiv="expires" content="0">    
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
    <h3>测试DbUtil.QueryRunner类</h3>
    <hr/>
    <%
    //QueryRunner dbQry = DbUtilHelper.createQueryRunner();
    //String selSql = "select id, name, age from user";
    //List<User> uList =  (List<User>)dbQry.query(selSql, new BeanListHandler(User.class));
    //out.println(uList);    
    //String inrSql = "insert into user(id, name, age) values(?,?,?)";
    out.println("<hr><br/>插入数据库记录");
    QueryRunner qry = DbUtilHelper.createQueryRunner();
	String sql = "update user set age=?, cdate=? where id=4";
	Object[] params = new Object[]{24, new java.util.Date()};
	int rtn = qry.update(sql, params);
	out.println("<h3>" + rtn + "</h3>");
    %>
    
  </body>
</html>
